//
//  WZTaskLogCell.m
//  WZEfengAndEtong
//
//  Created by wanzhao on 16/7/4.
//  Copyright © 2016年 wanzhao. All rights reserved.
//

#import "WZTaskLogCell.h"
#import "WZTaskLog.h"

@interface WZTaskLogCell ()

@property (weak, nonatomic) IBOutlet UILabel *dateLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UIView  *vSeprateView;
@property (weak, nonatomic) IBOutlet UIView  *hSeparteView;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *progressLabel;
@property (weak, nonatomic) IBOutlet UILabel *progressTitle;
@property (weak, nonatomic) IBOutlet UILabel *delayLabel;
@property (weak, nonatomic) IBOutlet UILabel *infoLabel;
@property (weak, nonatomic) IBOutlet UIView  *taskView;

@end

@implementation WZTaskLogCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
//    self.taskView.layer.cornerRadius = 10;
//    self.taskView.layer.masksToBounds = YES;
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
}

- (void)setTaskLog:(WZTaskLog *)taskLog {
    
    _taskLog = taskLog;
    
    NSString *dateString = [NSDate separteTimeStr:taskLog.createTime sepStr:@" "].firstObject;
    
    NSDate *date = [NSDate dateFromString:dateString format:@"yyyy-MM-dd"];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MM-dd"];
    NSString *dateStr = [formatter stringFromDate:date];
    
    NSString *timeStr = [NSDate separteTimeStr:taskLog.createTime sepStr:@" "].lastObject;
    
    self.dateLabel.text = dateStr;
    self.timeLabel.text = timeStr;
    self.name.text = taskLog.createName;
    self.delayLabel.text = taskLog.delayTime;
    self.infoLabel.text = taskLog.comments;
    
    switch (taskLog.type) {
        case 1:
            
        {
            self.progressTitle.hidden = NO;
            self.progressLabel.text = [NSString stringWithFormat:@"%@%%", taskLog.progress];
        }
            
        case 2:
            
        {
            if (taskLog.applyType == 1) { // 延期
                
                self.progressTitle.hidden = YES;
                self.progressLabel.text = @"延期申请";
                
            } else if (taskLog.applyType == 2) { // 申请完成
                
                self.progressTitle.hidden = YES;
                self.progressLabel.text = @"申请完成";
            }
        }
            break;
            
        case 3:
        
        {
            if (taskLog.auditStatus == 2) {
               
                self.progressTitle.hidden = YES;
                self.progressLabel.text = @"同意";
                
            } else if (taskLog.auditStatus == 3) {
                
                self.progressTitle.hidden = YES;
                self.progressLabel.text = @"拒绝";
            }
        }
            
        default:
            break;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
